﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BestLifePOS_Core.Data.Fascade;
using BestLifePOS_Core.Data.Core;
using System.Data.SqlClient;
using BestLifePOS_Core.Exceptions.DataBase;
using BestLifePOS_Core.DomainObjects;
using System.Data;

namespace BestLifePOS_Core.Data.Commands
{
    class BestlifeGetNameCmb : BestLifeDataAction<List<Product>>
    {
      private  string ValP = null;
        public BestlifeGetNameCmb()
        {

        }

        public override List<Product> Body(SqlConnection PConn)
        {
             try{
                
                //List<Product> PList = new List<Product>();
               
                 SqlCommand LvCommand = new SqlCommand();
                 LvCommand.Connection = PConn;
                 LvCommand.CommandType = CommandType.StoredProcedure;
                 LvCommand.CommandText = "dbo.GetProNamee";

                
                SqlDataReader LvReader = LvCommand.ExecuteReader();

                List<Product> lst = new List<Product>();

                 while (LvReader.Read())
                {

                    Product LvProDet = new Product();
               
                    LvProDet.Pro_Name = LvReader.GetValue(0).ToString();
                    LvProDet.Pro_ID = LvReader.GetValue(1).ToString();

                    lst.Add(LvProDet);
                    //ValP ="LvReader.GetValue(0).ToString()"+'-'+"LvReader.GetValue(1).ToString()";
                    //lst.Add(ValP);

                    ////PList.Add(Lvpro);
                }


                 return lst;
            }
            catch (BestlifeDatabaseException e)
            {
                throw new BestlifeDatabaseException(e);
            }

        }

   }
}
